<template>
    <div>
       <TaskProtable :isShowSelectInfo="false" :teamTaskData="teamTaskData"></TaskProtable>
    </div>
</template>

<script setup>

    import TaskProtable from "@/components/TaskProtable/index.vue"
    import {worksData} from "@/stores/worksData.js"
    import {ref,onMounted,onBeforeUnmount,getCurrentInstance,computed,provide} from "vue"
    import {mainStore} from "@/stores"


    // 提供数据给teamTask
    provide("state",0)
        provide("examine",0)

    let {proxy} = getCurrentInstance()

    let teamTaskData = computed(()=>{
        return mWorks.myTeamWorksdata
    })
    let mWorks = worksData()
    let mStores = mainStore()


    let current = ref(1)
    let take = ref(10)


    // 获取团队任务中的数据
    let getTeamWorksData = ()=>{
        let data = {
            state:2,
            current:current.value,
            take:take.value,
            staffId:mStores.userinfo.staffId
        }
        let res = mWorks.getOwnTaskData(data)
    }

    let changeCurrentPage = (e)=>{
        // console.log(e,"改变了当前页")
        current.value = e
        getTeamWorksData()
    }

    let changeSizePage = (e)=>{
        take.value = e
        current.value = 1
        getTeamWorksData()
        // console.log(e,"改变了页数")
    }


    onMounted(()=>{
        getTeamWorksData()
        proxy.$Bus.on("changeCurrentPage",changeCurrentPage)
        proxy.$Bus.on("changeSizePage",changeSizePage)

    })

    onBeforeUnmount(()=>{
        proxy.$Bus.off("changeCurrentPage",changeCurrentPage)
        proxy.$Bus.off("changeSizePage",changeSizePage)
    })

</script>

<style lang="scss" scoped>

</style>